<?php
if(empty($_GET) && empty($_POST)){
    header('location:index.php');
}
session_start();
include_once 'comm/config.php';
include_once 'comm/checkpostandget.php';

$url=$_GET['url']?base64_decode($_GET['url']):base64_decode($_POST['url']);
$pic=$_GET['pic']?base64_decode($_GET['pic']):base64_decode($_POST['pic']);

if($_GET['fan']!=''){
    $fan=$_GET['fan'];
}
elseif($_POST['fan']!=''){
    $fan=$_POST['fan'];
}
else{
    $fan=0;
}

$price=$_GET['price']?$_GET['price']:$_POST['price'];
$name=$_GET['name']?$_GET['name']:$_POST['name'];
$act=$_GET['act']?$_GET['act']:$_POST['act'];
$sid=$_GET['sid']?$_GET['sid']:$_POST['sid'];
$iid=$_GET['iid']?$_GET['iid']:$_POST['iid'];
$uid=$_SESSION['dduserid']?$_SESSION['dduserid']:0;
$input_arr=array('url'=>base64_encode($url),'pic'=>base64_encode($pic),'fan'=>$fan,'price'=>$price,'name'=>$name,'act'=>$act,'iid'=>$iid,'sid'=>$sid);
if($uid>0 && $url!=''){
	$url=add_uid_jump_url($url,$uid);
	if(!array_key_exists('p',$_POST)){
		$input_arr['p']=1;
	    echo postform('goto.php?act='.$act,$input_arr);
		exit;
	}
}

switch($act){
    case 'goods':
	    $fan.='元';
	    $mallname="淘宝";
		$iframe_url='http://item.taobao.com/item.htm?id='.$iid;
	break;
	case 'shop':
	    $fan.='%';
	    $mallname="淘宝";
		$iframe_url='http://shop'.$sid.'.taobao.com/';
		if($url==''){
			include_once 'comm/Taoapi.php';
			$Taoapi_Config = Taoapi_Config::Init();
            $Taoapi_Config->setCharset('UTF-8');
            $Taoapi = new Taoapi;
		    $Taoapi->method = 'taobao.taobaoke.shops.convert';
            $Taoapi->fields = 'click_url';
            $Taoapi->sids = $sid;
			$Taoapi->outer_code = $uid;
			$Taoapi->nick = MYUSERNICK;
            $ShopComm = $Taoapi->Send('get','xml')->getArrayData();
            $url=$ShopComm['taobaoke_shops']['taobaoke_shop']['click_url'];
		}
	break;
}

if($uid>0 && $url!=''){
	$url=add_uid_jump_url($url,$uid);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$name?> - <?=WEBTITLE?></title>
<link type="text/css" rel="stylesheet" href="css/alert.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="template/<?=MOBAN?>/js/base64.js"></script>
<script type="text/javascript" src="template/<?=MOBAN?>/js/function.js"></script>
<script type="text/javascript" src="js/fun.js"></script>
<script type="text/javascript" src="js/error.js"></script>
<style>
#desc{height:45px;font-size:14px;font-weight:bold}
#desc big{font-size:16px;color:#f00}
</style>
</head>
<body>
<iframe frameborder="0" scrolling="no" src="<?=$iframe_url?>" marginwidth="0" marginheight="0" width="100%" class="ifrnameurl" id="flboxcontent"></iframe>
<div class="alert_fullbg"></div>
<div class="alert_bg" id="alert_fast_log_reg" style="display: block;">
	<div class="alert_box">
<div class="alert_top"><span>请登录领取该商城的返利</span><a class="alert_close" href="<?=$url?>"></a></div>
<div class="alert_content">
<div class="sort_info">
<div class="sort_pic"><?=html_img($pic,$row["name"])?></div>
<em></em>
<div class="sort_price"><?php if($act=='goods'){?>淘宝价：<b class="red"><?=$price?>元</b><br/><?php }?>最高返：<b class="red"><?=$fan?></b>
</div>
<p><span class="blue">还不是<?=WEBNICK?>的会员？<a href="user/register.php" style="color:#F00; font-weight:bold" target="_blank">点击注册！</a></span><?php if($uid==0){?><a style="float:right" class="blue" href="<?=$url?>">不要返利,先看看>></a><?php }else{?><a style="float:right" class="blue" href="<?=$url?>">如果您的浏览器没有自动跳转，<b style="color:#F00">请点击这里</b></a><?php }?></p>
</div>
<?php if($uid>0){?>
<div class="login_reg" style="text-align:center">
<form name="loading" style=" width:100%;">
<div id="desc"><?=WEBTITLE?>正在带您去<big><?=$mallname?></big>（最高返<span style='color:#BD0000;'><?=$fan?></span>），请稍等</div>
<div id="tip" style="height:40px">
<input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:#fe6d01; background-color:#fff; padding:0px; border-style:none;">
<input name=percent size=47 style="color:#0066ff; text-align:center; border-width:medium; border-style:none;" type="hidden">
 </div>
 </form>
  </div>
<script>
function doClick(){
    var o=document.getElementById('goto');
    if(document.all){
        o.click();
    }else{
        window.location=o.href;
    }
}

var bar=0　 
var line="||"　 
var amount="||"　 
count();

function count(){　 
    bar=bar+2　 
    amount =amount + line　 
    document.loading.chart.value=amount　 
    document.loading.percent.value=bar+"%"　 
    if (bar<99){
		setTimeout("count()",10);
	}　 
    else{
        doClick();
    }　 
}
</script>
<?php }else{?>
<div class="login_reg">
<ul class="l_r_menu">
  <li><a href="javascript:;" class="l_log current">登录领取返利</a></li>
  <!--<li><a href="javascript:;" class="l_reg">注册领取返利</a></li>-->
</ul>
<div class="l_r_login" id="log">
  <div class="login">
  <form action="" method="post" onsubmit="return ajaxLogin(this)">
  
    <span class="fl">帐号：</span><input type="text" value="" class="login_name"  tabindex="1" name="ddusername" id="username1" />
    <div style="clear:both"></div>
    <span class="fl">密码：</span><input type="password" class="login_pwd"  tabindex="2" name="dduserpwd" id="password1"/>
    <div style="clear:both"></div>
    <font><input type="checkbox" class="checkbox" value="1" name="remember" id="remember" checked="checked"><label for="checkbox">记住我<span>（3个月免登陆）</span></label></font>
    <div style="clear:both"></div>
    <input type="hidden" name="submit" value="1" />
    <div style="margin-top:10px;">
    <div style="float:left;margin-left:50px; _margin-left:20px"><input type="submit" class="button" value="登 录"  tabindex="3" /></div><div style="float:left;margin-left:20px;"><a href="user/getpassword.php" class="fo_psw" target="_blank">忘记密码?</a></div>
    </div>
    <div style="clear:both"></div>
  </form>
  </div>
  <div class="union_login"><p>友情提示：</p><div style="line-height:20px">虚拟商品如话费，<br/>游戏，机票等无<br/>返利哦！</div></div>
</div>
  </div>
<?php }?>
</div>
</div>

</div>
<a id="goto" href="<?=$url?>">&nbsp;</a>
<script src="js/jquery.validate.js"></script>
<script type="text/javascript">
input=new Array();
input['url']='<?=base64_encode($url)?>';
input['pic']='<?=base64_encode($pic)?>';
input['fan']='<?=$_GET['fan']?>';
input['price']='<?=$price?>';
input['name']='<?=$name?>';
input['p']=1;
input['iid']='<?=$iid?>';
input['sid']='<?=$sid?>';
(function($) {
    var iheight;
    iheight = $(window).height();
    $('#flboxcontent').attr('height', iheight + 'px');
    $(window).resize(function() {
        iheight = $(window).height();
        $('#flboxcontent').attr('height', iheight + 'px');
    });
    var top = $(window).height() / 2 - $("#alert_fast_log_reg").height() / 2;
    var left = $(window).width() / 2 - $("#alert_fast_log_reg").width() / 2;
    $("#alert_fast_log_reg").css("left", left);
    $("#alert_fast_log_reg").css("top", top);
})(jQuery);

$(function(){
    $('.l_r_menu li a').click(function(){
	    $('.l_r_menu li a').removeClass('current');
		var classname=$(this).attr('class');
		if(classname=='l_log'){
		    $('#reg').hide();
			$('#log').show();
		}
		else if(classname=='l_reg'){
		    $('#log').hide();
			$('#reg').show();
		}
		$(this).addClass('current');
	});
});

function ajaxLogin(t){
	$.post('ajax.php?fun=checkLogin',$(t).serialize(),function(data){
		if(parseInt(data)>0){
			postForm('goto.php?act=<?=$act?>',input);
		}
		else{
		    alert('账号密码错误');
		}
	});
	return false;
}

$(function(){
    $('#register_form').validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('td').next('td');
            error_td.find('.field_notice').hide();
            error_td.append(error);
        },
        success       : function(label){
            label.addClass('validate_right').text('OK!');
        },
        onkeyup: false,
        rules : {
            username : {
                required : true,
                byteRange: [3,15,'utf-8']
            },
            password : {
                required : true,
                minlength: 6
            },
            password_confirm : {
                required : true,
                equalTo  : '#password'
            },
            email : {
                required : true,
                email    : true
            },
            qq : {
                required : true,
                range:[1000,999999999999]
            },
			captcha : {
                required : true,
                rangelength:[4,4],
				digits:true
            }
        },
        messages : {
            username : {
                required : '您必须提供一个用户名',
                byteRange: '用户名必须在3-15个字符之间'
            },
            password  : {
                required : '您必须提供一个密码',
                minlength: '密码长度应在6-20个字符之间'
            },
            password_confirm : {
                required : '您必须再次确认您的密码',
                equalTo  : '两次输入的密码不一致'
            },
            email : {
                required : '您必须提供您的电子邮箱',
                email    : '这不是一个有效的电子邮箱'
            },
			qq : {
                required : '您必须提供您的QQ号码',
                range:'QQ号码位数错误'
            },
            captcha : {
                required : '请输入右侧图片中的字符',
				rangelength    : '位数错误',
				digits   : '这不是一个数字'
            }
        },
		submitHandler: function(form) {
            $.post('register.mod.php',$('#register_form').serialize(),function(data){//alert(data);
		        if(data=='ok'){
		            postForm('goto.php?act=<?=$act?>',input);
		        }
		        else{
		            alert(errorArr[data]);
		        }
	        });
        }
    });
});
</script>

</body>
</html>
